package com.sunda.spmsweb.ordercontroller;


import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmsorder.service.IMaterialSrmLongContractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * SRM长协表 前端控制器
 * </p>
 *
 * @author Wayne
 * @since 2021-01-25
 */
@RestController
@RequestMapping("/srmLongContract")
@Api(tags = "SRM 物料长协信息接口", description = "srm 物料长协信息接口")
public class MaterialSrmLongContractController {

    @Autowired
    IMaterialSrmLongContractService iMaterialSrmLongContractService;

    @RequestMapping("/getByMaterialNoList")
    @ApiOperation(value = "根据物料编号查询长协/多个料号",notes = "根据物料编号查询长协信息\nmaterialNo = 130011850,210036864,130011853", httpMethod = "POST")
    public ResponseResult getByMaterialNoList(String materialNoList) {
        try {
            return ResponseResult.success().add("materialSrmSourceList", iMaterialSrmLongContractService.getByMaterialNoList(materialNoList));
        }catch (Exception e){
            e.printStackTrace();
            return ResponseResult.error("请求目录数据失败").add("msg", e);
        }
    }

    @RequestMapping("/getByMaterialNo")
    @ApiOperation(value = "根据物料编号查询长协/一个料号",notes = "根据物料编号查询长协信息\nmaterialNo = 130011850", httpMethod = "POST")
    public ResponseResult getByMaterialNo(String materialNo) {
        try {
            return ResponseResult.success().add("materialSrmSourceList", iMaterialSrmLongContractService.getByMaterialNo(materialNo));
        }catch (Exception e){
            e.printStackTrace();
            return ResponseResult.error("请求目录数据失败").add("msg", e);
        }
    }
}
